package com.msh.artascope.devcloud.service.controller;

import com.msh.artascope.devcloud.client.po.DomainConfigPo;
import com.msh.artascope.devcloud.client.qo.DomainConfigQo;
import com.msh.artascope.devcloud.service.service.DomainConfigService;
import com.msh.frame.client.common.Result;
import com.msh.frame.client.validation.IList;
import com.msh.frame.web.base.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 域名配置-controller相关接口
 *
 * @author shihu
 * @email m-sh@qq.com
 */
@Tag(name = "域名配置-controller相关接口")
@RestController
@RequestMapping("/domainConfig")
@Slf4j
public class DomainConfigController extends BaseController<DomainConfigPo, DomainConfigQo> {

  @Resource
  private DomainConfigService domainConfigService;

  /**
   * 域名配置详情
   *
   * @param id
   * @param tenantId
   * @return
   */
  @Operation(summary = "域名配置详情")
  @GetMapping("get")
  public Result<DomainConfigPo> get(@NotNull(message = "id不能为空") @RequestParam("id") Long id,
      @NotNull(message = "tenantId不能为空") @RequestParam("tenantId不能为空") Long tenantId) {
    return Result.successReturn(domainConfigService.get(id, tenantId));
  }

  /**
   * 域名配置列表查询
   *
   * @param q
   * @return
   */
  @Operation(summary = "域名配置列表查询")
  @PostMapping("list")
  public Result<List<DomainConfigPo>> list(
      @Validated({IList.class, Default.class}) @RequestBody DomainConfigQo q) {
    return Result.successReturn(domainConfigService.list(q));
  }

}
